/**
 *                     Remixvym (version 0.8.3)
 *             Copyright (c) 2010 by RemixLab, DISI-UNAL
 *            http://www.disi.unal.edu.co/grupos/remixlab/
 *
 * This Java package provides classes to visualize Mind Maps created in VYM
 * (View Your Mind) in a Processing Sketch
 *
 * @author Alvaro Lopez, Juan Baquero
 *
 * This source file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * A copy of the GNU General Public License is available on the World Wide Web
 * at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by
 * writing to the Free Software Foundation, 51 Franklin Street, Fifth Floor
 * Boston, MA 02110, USA
 */
package remixlab.remixvym.core.graphics.link;

import processing.core.PApplet;
import remixlab.remixvym.core.mindmap.Node;
import processing.core.PGraphics;

/** 
 * Draws a line link type between the linked nodes.<p>
 * Implements LinkForm {@link remixlab.remixvym.core.graphics.link.LinkForm}
 */

public class LineLink implements LinkForm{

	/** 
	 * Draws a line link type between the linked nodes.<p>
	 * <b>See examples: </b> LineStyle
	 * @param node
	 * @param parent PApplet from processing
	 */	
	public void drawLine(Node node, PApplet parent, PGraphics pg) {
		
		if(node.hide) return;
		
		if(node.getFather()==null)
			return;
		if(node.x1>node.getFather().x1){
			/*parent.line((node.x1),
				    (node.y1 + (int)(0.5*node.height)),
				    (node.getFather().x1 + node.getFather().width),
				    (node.getFather().y1 + (int)(0.5*node.getFather().height)));*/
			pg.line((node.x1),
				    (node.y1 + (int)(0.5*node.height)),
				    (node.getFather().x1 + node.getFather().width),
				    (node.getFather().y1 + (int)(0.5*node.getFather().height)));
		}
		else{
			/*parent.line((node.x2),
				    (node.y1 + (int)(0.5*node.height)),
				    (node.getFather().x1 ),
				    (node.getFather().y1 + (int)(0.5*node.getFather().height)));*/
			pg.line((node.x2),
				    (node.y1 + (int)(0.5*node.height)),
				    (node.getFather().x1 ),
				    (node.getFather().y1 + (int)(0.5*node.getFather().height)));
			//pg.line(node.x2, node.y1, 0, 0);
		}
	}
}
